package com.pmgames.vo;

public class Content implements IXmlSerializable {

	private int id;
	private String shortName;
	private String name;
	private String definition;
	private String type;
	private Course course;
	private Module module;
	private String image;
	
	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDefinition() {
		return definition;
	}

	public void setDefinition(String definition) {
		this.definition = definition;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Course getCourse() {
		return course;
	}

	public void setCourse(Course course) {
		this.course = course;
	}

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Content() {		
	}
	
	public Content(Content word) {	
		setId(word.getId());
		setName(word.getName());
		setShortName(word.getShortName());
		setDefinition(word.getDefinition());
		setCourse(word.getCourse());
		setModule(word.getModule());
		setType(word.getType());
		setImage(word.getImage());
	}
	
	public Content encodeWord()
	{
		Content encoded = new Content(this);
		String encodedWrd = new String();
		encodedWrd += getName().charAt(0);
  		for(int index = 1; index < getName().length() - 1; index++)
  		{
  			encodedWrd +=  "_";
  		}
  		encodedWrd += getName().charAt(getName().length() - 1);
  		encoded.setName(encodedWrd);
  		return encoded;
	}
	
	/* (non-Javadoc)
	* @see java.lang.Object#equals(java.lang.Object)
	*/
	@Override
	public boolean equals(Object arg0) {
		return this.id == ((Content)arg0).getId();
	}

	@Override
	public String toXml() {
		String xml = "<wordsExp>";
		xml += "<id>" + id + "</id>";
		xml += "<shortName>" + shortName + "</shortName>";
		xml += "<name>" + name + "</name>";
		xml += "<definition>" + definition + "</definition>";
		xml += "<type>" + type + "</type>";
		xml += "<course>" + course.toXml() + "</course>";
		xml += "<module>" + module.toXml() + "</module>";
		xml += "<image>" + image + "</image>";
		xml += "</wordsExp>";
		return xml;
	}

}
